package com.ruoyi.reservationmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.reservationmanagement.domain.Reservationmanagement;
import com.ruoyi.reservationmanagement.service.IReservationmanagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/reservationmanagement/reservationmanagement")
public class ReservationmanagementController extends BaseController
{
    @Autowired
    private IReservationmanagementService reservationmanagementService;

    /**
     * 查询预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('reservationmanagement:reservationmanagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(Reservationmanagement reservationmanagement)
    {
        startPage();
        List<Reservationmanagement> list = reservationmanagementService.selectReservationmanagementList(reservationmanagement);
        return getDataTable(list);
    }

    /**
     * 导出预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('reservationmanagement:reservationmanagement:export')")
    @Log(title = "预约管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Reservationmanagement reservationmanagement)
    {
        List<Reservationmanagement> list = reservationmanagementService.selectReservationmanagementList(reservationmanagement);
        ExcelUtil<Reservationmanagement> util = new ExcelUtil<Reservationmanagement>(Reservationmanagement.class);
        util.exportExcel(response, list, "预约管理数据");
    }

    /**
     * 获取预约管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('reservationmanagement:reservationmanagement:query')")
    @GetMapping(value = "/{reservationId}")
    public AjaxResult getInfo(@PathVariable("reservationId") Long reservationId)
    {
        return success(reservationmanagementService.selectReservationmanagementByReservationId(reservationId));
    }

    /**
     * 新增预约管理
     */
    @PreAuthorize("@ss.hasPermi('reservationmanagement:reservationmanagement:add')")
    @Log(title = "预约管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Reservationmanagement reservationmanagement)
    {
        return toAjax(reservationmanagementService.insertReservationmanagement(reservationmanagement));
    }

    /**
     * 修改预约管理
     */
    @PreAuthorize("@ss.hasPermi('reservationmanagement:reservationmanagement:edit')")
    @Log(title = "预约管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Reservationmanagement reservationmanagement)
    {
        return toAjax(reservationmanagementService.updateReservationmanagement(reservationmanagement));
    }

    /**
     * 删除预约管理
     */
    @PreAuthorize("@ss.hasPermi('reservationmanagement:reservationmanagement:remove')")
    @Log(title = "预约管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reservationIds}")
    public AjaxResult remove(@PathVariable Long[] reservationIds)
    {
        return toAjax(reservationmanagementService.deleteReservationmanagementByReservationIds(reservationIds));
    }
}
